﻿/*
 * Copyright (c) 2013, Juergen Bocklage-Ryannel, Johan Thelin
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the editors nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

// showcase.qml

//导入 Qt快速 2.5
import QtQuick 2.5
//导入 Qt绘画效果 1.0
import QtGraphicalEffects 1.0

Image {
    //设置ID为root，root为根本的意思
    id: root
    //设置本模块资源，资源路径相对路径为 "images/background.png"
    source: "images/background.png"

    //设置跟属性blurRadius为0
    property int blurRadius: 0

    Image {
        //设置ID为pole，pole为杆的意思
        id: pole
        //设置本身的中心为父模块的中心
        anchors.horizontalCenter: parent.horizontalCenter
        //设置本身的底部为父模块的底部
        anchors.bottom: parent.bottom
        //设置本模块资源，资源路径相对路径为 "images/pole.png"
        source: "images/pole.png"
    }


    Image {
        //设置ID为wheel，wheel为轮子的意思
        id: wheel
         //设置本身的中心为父模块的中心
        anchors.centerIn: parent
        //设置本模块资源，资源路径相对路径为 "images/pinwheel.png"
        source: "images/pinwheel.png"
        //设置旋转行为，Behavior是行为的意思，当关联的值改变时会自动触发下面的函数
        Behavior on rotation {
            //动作延迟250毫秒
            NumberAnimation {
                duration: 250
            }
        }
        //layer.effect 待定
        layer.effect: FastBlur {
            //设置ID为blur，blur为变模糊的意思
            id: blur
           //设置radius为根属性blurRadius，radius为半径的意思
            radius: root.blurRadius
            //设置行为半径，Behavior是行为的意思，当关联的值改变时会自动触发下面的函数
            Behavior on radius {
                //动作延迟250毫秒
                NumberAnimation {
                    duration: 250
                }
            }
        }
        //layer.enabled 待定
        layer.enabled: true
    }

    //鼠标事件区域
    MouseArea {
        //绑定填充为父模块
        anchors.fill: parent
        //按下动作时响应
        onPressed: {
            //轮子的旋转属性+90,并触发上面 Behavior on rotation 行为。
            wheel.rotation += 90
            //根的模糊半径属性+16,并触发上面 Behavior on radius 行为。
            root.blurRadius = 16
        }
       //松开动作时响应
        onReleased: {
            //根的模糊半径属性 = 0
            root.blurRadius = 0
        }
    }
}
